package sf.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JSeparator;
import javax.swing.border.EmptyBorder;

public class StatusBar extends JPanel {

	private static final long serialVersionUID = 1L;

	private JPanel panelLabels;

	private JLabel labelMode;
	private JLabel labelInfo;
	private JProgressBar progressBar;

	public StatusBar() {
		init();
	}

	private void init() {
		setLayout(new BorderLayout());
		setBorder(new EmptyBorder(0, 5, 0, 5));

		panelLabels = new JPanel();
		panelLabels.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));

		JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);

		labelMode = new JLabel("");
		labelMode.setHorizontalAlignment(JLabel.LEFT);
		labelMode.setForeground(Color.gray);

		labelInfo = new JLabel("");
		labelInfo.setHorizontalAlignment(JLabel.LEFT);
		labelInfo.setForeground(Color.gray);

		progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
		progressBar.setIndeterminate(true);
		progressBar.setBorderPainted(false);
		progressBar.setVisible(false);

		panelLabels.add(labelMode);
		panelLabels.add(labelInfo);

		add(separator, BorderLayout.NORTH);
		add(panelLabels, BorderLayout.WEST);
		add(progressBar, BorderLayout.EAST);
	}

	public void setMode(String mode) {
		labelMode.setText("<html>mod: <b>" + mode + "</b></html>");
	}

	public void setInfo(String text) {
		labelInfo.setText(text);
	}

	public void showProgressBar(boolean isVisible) {
		progressBar.setVisible(isVisible);
	}
}
